﻿using NaturalNote.Core.Database;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace NaturalNote.Mysql
{
    internal class MysqlDataQuery : IDataQuery
    {
        IDbConnection dbConnection;
        public MysqlDataQuery(IDbConnection dbConnection)
        {
            this.dbConnection = dbConnection;
        }
        public Task<T> Get<T>(string sql, object? param = null)
        {
            return dbConnection.QueryFirstOrDefaultAsync<T>(sql, param);
        }

        public Task<IEnumerable<T>> Query<T>(string sql, object? param = null)
        {
            return dbConnection.QueryAsync<T>(sql, param);
        }
    }
}
